package br.com.portalecbahia.connectionservices;


import twitter4j.Twitter;
import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
import br.com.portalecbahia.listner.TwitterListeners;
import br.com.portalecbahia.util.PortalECBahiaUtil;

public class SynchronizeTwitter extends AsyncTask<String, Void, Boolean> {
	
	private Context context;
	private TwitterListeners listeners;
	private Twitter mTwitter;
	
	public SynchronizeTwitter(Twitter mTwitter, Context context){
	
		this.mTwitter = mTwitter;
		this.context = context;
		
		this.listeners = (TwitterListeners)context;
	}
	@Override
	protected void onPreExecute() {
	
	}
	
  
    @Override
    protected void onPostExecute(Boolean result) {               
    	listeners.onSynchronizeTwitComplete(result);
    
    }

    @Override
	protected Boolean doInBackground(String... params) {
		try{
			
			String twit = params[0];
			mTwitter.updateStatus(twit);
		}catch (Exception e) {
			Log.e(PortalECBahiaUtil.TAG, e.toString());
			return  false;
		}
		return true;
		
	}
}
